mkFlakePackages: only expose components in the install plan (#2028) - #2548
Open
hamishmack wants to merge 1 commit into
Open
mkFlakePackages: only expose components in the install plan (#2028)#2548hamishmack wants to merge 1 commit into
hamishmack wants to merge 1 commit into
Conversation
mkFlake exposed every component of every local package as a flake package, so a private sub-library that exists only to serve a disabled test suite was still built by hydraJobs.packages (#2028). Filter mkFlakePackages/mkFlakeApps on the component's buildable/planned flags (reachable via the component's passthru.config), mirroring the buildable && planned filter already used by config.allComponent and applyComponents. A component is excluded only when it is explicitly planned = false, so nothing currently exposed is hidden unless the install plan itself says it is not planned. Adds runnable unit tests for the predicate and the filter in test/unit.nix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mkFlakeexposed every component of every local package as a flake package, so a private sub-library that exists only to serve a disabled test suite was still built byhydraJobs.packages(#2028). The right criterion (andreabedini's, on the issue) is: build exactly the components that appear in the cabal install plan.mkFlakePackagesandmkFlakeAppsnow skip components that are not in the plan, using a smallflakeComponentIsPlannedpredicate:plannedis set totruebyplan-to-nixfor every component inplan.json(project-wide for stack projects);buildablecomes from the.cabalfile / module overrides. These are reachable on a built component via itspassthru.config(builder/comp-builder.nix).buildable && plannedfilter already used byconfig.allComponent(modules/package.nix) andapplyComponents(lib/default.nix), so flakepackagesnow agree with what the rest of the code already considers "real".Safety
plannedis a plainbool(defaultfalse), so there is no null/unknown case: excludingplanned == falseis exactly "requireplanned == true", which is the same condition the existingallComponent/applyComponentsfilters use. A component is dropped only when the install plan says it is not planned — nothing currently exposed is hidden otherwise.Scope kept tight: this changes flake
packages/apps(the subject of the issue). The checks-collection path (collectChecks'/mkFlakeChecks) is left as-is.Tests
Added two runnable unit tests in
test/unit.nix(they exercise the realhaskellLib.mkFlakePackages/haskellLib.flakeComponentIsPlanned, not a copy):test-flakeComponentIsPlanned— the predicate's truth table incl. default handling.test-mkFlakePackages-filters-unplanned— a package fixture whose unplanned private sub-library and disabled test suite are dropped, while the planned library, sub-library and exe are kept.Ran the full
unit.testssuite locally (nix-build … -A unit.teststhennix-instantiate --eval --strict … -A unit.tests) →[](all pass, including the two new tests).Caveats
plan-nixin this environment failed on an unrelated environmental fixed-output hash mismatch fetching thehead.hackageindex. The unit tests exercise the actual exported code path, and reachability of.config.planned/.config.buildableon built components is guaranteed by existing code that already reads those same fields on the same config object.Closes #2028.